package cs.rsa.ts14.circuitbreaker.states;

import cs.rsa.ts14.circuitbreaker.CircuitBreaker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HalfOpen extends CircuitBreakerState {
    Logger logger = LoggerFactory.getLogger(HalfOpen.class);

	public HalfOpen(CircuitBreaker circuitBreaker) {
		super(circuitBreaker);
        logger.info("halfopen");
    }

	@Override
	public void exceptionOccurred(Exception e) {
		super.exceptionOccurred(e);
		circuitBreaker.moveToOpenState();
	}

	@Override
	public void protectedCodeHasBeenCalled() {
		super.protectedCodeHasBeenCalled();
		circuitBreaker.moveToClosedState();
	}
}
